<% layout('/layouts/default.html', {title: '服务订单查询', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text('服务订单详情')}

				<!--<button type="button" class="btn btn-primary" id="goBZJ"> ${text('保证金预收支')}</button>
                <button type="button" class="btn btn-primary" id="goDLFYSZ"> ${text('代理费预收支')}</button>
                <button type="button" class="btn btn-primary" id="goDLFSZ"> ${text('代理费收支')}</button>
                <button type="button" class="btn btn-primary" id="goYS"> ${text('预收费用')}</button>
                <button type="button" class="btn btn-primary" id="arriveReminder">${text('到单提醒')}</button>
                <button type="button" class="btn btn-primary" id="overseaswarehouse">${text('海外仓')}</button>
                <button type="button" class="btn btn-primary" id="submit"> ${text('提交')}</button>
                <button type="button" class="btn btn-primary" id="ok"> ${text('通过')}</button>
                <button type="button" class="btn btn-primary" id="reject"> ${text('拒绝')}</button>
                <button type="button" class="btn btn-primary" id="cancel"> ${text('取消订单')}</button>
                <button type="button" class="btn btn-primary" id="updateVersion"> ${text('更新版本')}</button>
                <a href="${ctx}/order/serviceorder/serviceOrder/lotNumberForm?serviceOrderId=${serviceOrder.serviceOrderId}" id="btnNewFolder"
                   class="btn btn-primary addTabPage" title="${text('录入批单号')}"
                   data-layer="true" data-layer-width="400" data-layer-height="200"
                > ${text('录入批单号')}</a>
                <button type="button" class="btn btn-primary" id="goLetterCredit"> ${text('开信用证')}</button>
                <button type="button" class="btn btn-primary" id="goServiceInvoice"> ${text('服务发票')}</button>-->

				<!--审批状态等于 编辑1 或 拒绝4 -->
				<% if (serviceOrder.approveStatus == "1" || serviceOrder.approveStatus == "4"){ %>
                    <% if (hasPermi('order:serviceorder:serviceOrder:edit')){ %>
                    <button type="button" class="btn btn-primary" id="editView">${text('编辑单据')}</button>
                    <% } %>
				    <button type="button" class="btn btn-primary" id="submit"> ${text('提交')}</button>
				<% } %>
				<!--审批状态等于 提交2 -->
				<% if (serviceOrder.approveStatus == "2" && hasPermi('order:serviceorder:serviceOrder:approve')){ %>
				<button type="button" class="btn btn-primary" id="ok"> ${text('通过')}</button>
				<button type="button" class="btn btn-primary" id="reject"> ${text('拒绝')}</button>
				<% } %>
				<!--预收款  预付款    -->
				<% if ((serviceOrder.bzjYusId == "" || serviceOrder.bzjYusId == null) && (serviceOrder.bzjYufId == "" || serviceOrder.bzjYufId == null)
				&& (serviceOrder.dlfYusId == "" || serviceOrder.dlfYusId == null) && (serviceOrder.dlfYufId == "" || serviceOrder.dlfYufId == null)
				&& (serviceOrder.ysfyId == "" || serviceOrder.ysfyId == null) && (serviceOrder.letterCreditCode == "" || serviceOrder.letterCreditCode == null)
				&& (serviceOrder.dlfYifId == "" || serviceOrder.dlfYifId == null) && (serviceOrder.dlfYisId == "" || serviceOrder.dlfYisId == null)
				&& serviceOrder.arrivalReminderCode == false && serviceOrder.overseasWarehouseCode == true && hasPermi('order:serviceorder:serviceOrder:cancel') ){ %>
				<button type="button" class="btn btn-primary" id="cancel"> ${text('作废')}</button>
				<% } %>


				<!--预收款  预付款-->
				<!--<% if (hasPermi('prerecieve:tadvancesReceived:edit') && hasPermi('prepay:tprepayment:edit')){ %>-->
				<% if ((serviceOrder.bzjYusId == null || serviceOrder.bzjYusId == "") || (serviceOrder.bzjYufId == null || serviceOrder.bzjYufId == "")){ %>
                    <% if (hasPermi('order:serviceorder:serviceOrder:bzjysz')){ %>
                    <button type="button" class="btn btn-primary" id="goBZJ"> ${text('保证金预收支')}</button>
                    <% } %>
				<% } %>
				<% if ((serviceOrder.dlfYusId == "" || serviceOrder.dlfYusId == null) || (serviceOrder.dlfYufId == "" || serviceOrder.dlfYufId == null)){ %>
                    <% if (hasPermi('order:serviceorder:serviceOrder:dlfysz')){ %>
                    <button type="button" class="btn btn-primary" id="goDLFYSZ"> ${text('代理费预收支')}</button>
                    <% } %>
				<% } %>
				<!--<% } %>-->

				<!--预收款 -->
				<% if ((serviceOrder.ysfyId == "" || serviceOrder.ysfyId == null) && hasPermi('order:serviceorder:serviceOrder:ysfy')){ %>
				<button type="button" class="btn btn-primary" id="goYS"> ${text('预收费用')}</button>
				<% } %>

				<!-- 单据状态为执行中3-->
				<% if (serviceOrder.orderStatus == "3"){ %>
				<!--应收单 应付单 -->
				<% if (hasPermi('order:serviceorder:serviceOrder:dlfsz')
				&& ((serviceOrder.dlfYifId == "" || serviceOrder.dlfYifId == null) || (serviceOrder.dlfYisId == "" || serviceOrder.dlfYisId == null))){ %>
				<button type="button" class="btn btn-primary" id="goDLFSZ"> ${text('代理费收支')}</button>
				<% } %>

				<% if (hasPermi('order:serviceorder:serviceOrder:newversion')){ %>
				<button type="button" class="btn btn-primary" id="updateVersion"> ${text('更新版本')}</button>
				<% } %>

				<!-- 审批状态为通过3 -->
				<% if (serviceOrder.approveStatus == "3"){ %>

				<% if (hasPermi('order:serviceorder:serviceOrder:pdhlr')){ %>
				<a href="${ctx}/order/serviceorder/serviceOrder/lotNumberForm?serviceOrderId=${serviceOrder.serviceOrderId}" id="btnNewFolder" class="btn btn-primary addTabPage"
				   title="${text('录入批单号')}" data-layer="true" data-layer-width="400" data-layer-height="200" > ${text('录入批单号')}</a>
				<% } %>

				<% if (hasPermi('order:serviceorder:serviceOrder:serviceinvoice')){ %>
				<button type="button" class="btn btn-primary" id="goServiceInvoice"> ${text('服务发票')}</button>
				<% } %>

				<!-- 付款方式不等于TT 3 -->
				<% if (serviceOrder.paymentMethod != "3"){ %>
                    <% if (hasPermi('order:serviceorder:serviceOrder:kxyz') && (serviceOrder.letterCreditCode == "" || serviceOrder.letterCreditCode == null)){ %>
                    <button type="button" class="btn btn-primary" id="goLetterCredit"> ${text('开信用证')}</button>
                    <% } %>
                    <% if (hasPermi('order:serviceorder:serviceOrder:ddtx') && !(serviceOrder.letterCreditCode == "" || serviceOrder.letterCreditCode == null)){ %>
                    <button type="button" class="btn btn-primary arriveReminder">${text('到单提醒')}</button>
                    <% } %>
				<% } %>

				<!-- 付款方式等于TT 3 -->
				<% if (serviceOrder.paymentMethod == "3" && serviceOrder.overseasWarehouseCode == true){ %>
				<button type="button" class="btn btn-primary" id="overseaswarehouse">${text('海外仓')}</button>
				<% } %>
				<% if ( hasPermi('order:serviceorder:serviceOrder:ddtx') && serviceOrder.paymentMethod == "3" && serviceOrder.arrivalReminderCode == true ){ %>
				<button type="button" class="btn btn-primary arriveReminder" >${text('到单提醒')}</button>
				<% } %>
				<% } %>
				<% } %>
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${serviceOrder}" action="${ctx}/order/serviceorder/serviceOrder/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('基本信息')}</div>
			<#form:hidden path="serviceOrderId" id="serviceOrderId"/>
			<#form:hidden path="bzjYusId" id="bzjYusId"/>
			<#form:hidden path="bzjYufId" id="bzjYufId"/>
			<#form:hidden path="ysfyId" id="ysfyId"/>
			<#form:hidden path="dlfYusId" id="dlfYusId"/>
			<#form:hidden path="dlfYufId" id="dlfYufId"/>
			<#form:hidden path="dlfYifId" id="dlfYifId"/>
			<#form:hidden path="dlfYisId" id="dlfYisId"/>
			<#form:hidden path="customerId" id="customerCode"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('编号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="serviceOrderCode" maxlength="100" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('国内资方')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="investorId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('代理公司')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:treeselect id="company" title="${text('公司选择')}"
							path="company.companyCode" labelPath="company.companyName"
							url="${ctx}/sys/company/treeData" canSelectRoot="true" canSelectParent="true"
							class=" required" allowClear="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('年度汽车买卖协议')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="yearCarSalePurchaseAgreementId" maxlength="64" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('客户')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="customerId" items="${customerList}" itemLabel="customerName" itemValue="customerId"  blankOption="true" class="form-control" disabled="true" readonly="true" />

							<!--<#form:treeselect id="customer" title="${text('客户选择')}"
                            path="customer.customerId" labelPath="customer.customerName"
                            url="${ctx}/base/customer/customer/treeData" canSelectRoot="true" canSelectParent="true"
                            class=" required" allowClear="true" readonly="true"/>-->
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('汽车买卖合同号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="contractNumber" maxlength="50" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('供应链服务协议')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="supplyChainServiceAgreementId" maxlength="64" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('外商')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="foreignBusinessmenId" items="${hwzfList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control required" readonly="true" blankOption="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('采购委托书号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="purchaseCommissionNumber" maxlength="100" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('供货外商')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="supplierId" items="${ghwsList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('外贸合同号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="foreignTradeContractNumber" maxlength="100" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('付款方式')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="paymentMethod" dictType="payment_method" class="form-control required"
							blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('订单日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="date" readonly="true" maxlength="20" class="form-control required"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('状态')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('状态')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="orderStatus" dictType="order_status" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('审批状态')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="approveStatus" dictType="finance_bill_status" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('交易信息')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('最晚装船日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="latestShipmentDate" readonly="true" maxlength="20" class="form-control required"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('装运港')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="fromPort" dictType="erp_harbor_list" class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('目的港')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="toPort" dictType="erp_harbor_list" class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('贸易术语')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="tradeTerm" dictType="trade_term" class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('币种')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="currency" dictType="sys_bizhong" class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('资方利润')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="investorProfit" class="form-control required number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('批单号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="lotNumber" maxlength="100" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('车辆信息&风险保证金')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('保证金、费用比例')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="marginExpenseRatioId" itemLabel="name" itemValue="id"
							class="form-control required" blankOption="true" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('保证金比例')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="marginRatio" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('押汇比例')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="negotiatedRatioId" maxlength="64" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('预收费比例')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="prePayRatio" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('暂定汇率')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="tentativeExchangeRate" maxlength="10" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('服务订单明细')}</h4>
			<div class="ml10 mr10">
				<table id="serviceOrderDetailDataGrid"></table>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('车辆主要配置/备注')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('附件上传')}</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">
							<span class="required hide">*</span> ${text('附件上传')}：</label>
						<div class="col-sm-10">
							<#form:fileupload id="uploadFile" bizKey="${serviceOrder.id}" bizType="serviceOrder_file"
							uploadType="all" class="" readonly="false" preview="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('版本信息')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('版本号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="version" class="form-control digits" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('系统信息')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createBy" maxlength="64" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createDate" readonly="true" maxlength="20" class="form-control "
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateBy" maxlength="64" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateDate" class="form-control " readonly="true"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
			</div>
			<div class="form-unit">${text('相关记录')}</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('信用证')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="letterCreditCode" items="${listLetterCredit}"
							itemLabel="letterCreditCode" itemValue="letterCreditId" blankOption="true" class="form-control required" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="ml10 mr10">
				<table id="serviceOrderDetailDataGrid1"></table>
			</div>
		</div>
		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
				</div>
			</div>
		</div>
	</#form:form>
</div>
</div>
<% } %>
<script>
	//初始化服务订单明细DataGrid对象
	$("#serviceOrderDetailDataGrid").dataGrid({

		data: ${toJson(serviceOrder.serviceOrderDetailList)},
		datatype: "local", // 设置本地数据
		autoGridHeight: function(){return 'auto'}, // 设置自动高度

		// 设置数据表格列
		columnModel: [
			{header:'状态', name:'status', editable:true, hidden:true},
			{header:'主键', name:'serviceOrderDetailId', editable:true, hidden:true},
			{header:'${text("车辆as")}', name:'tcar.carName', index:'tcar.carName', width:200},
			{header:'${text("车架号")}', name:'frameNumber', width:150, editable:true, edittype:'text'},
			{header:'${text("品牌")}', name:'brand', width:150,
				editable:true, edittype:'select', formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('car_pinpai')}, val, '${text("未知")}', true);
				}
			},
			{header:'${text("版型")}', name:'area', width:150, editable:true, edittype:'text', formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('car_quyu')}, val, '${text("未知")}', true);
				}},
			{header:'${text("车型")}', name:'model', width:150, editable:true, edittype:'text'},
			{header:'${text("排量")}', name:'displacement', width:100, editable:true, edittype:'text'},
			{header:'${text("能源类型")}', name:'energyType', width:100,
				editable:true, edittype:'select', formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('car_nengyuanleixing')}, val, '${text("未知")}', true);
				}
			},
			{header:'${text("海关税率")}', name:'customsTariffRate', width:100, editable:true, edittype:'text'},
			{header:'${text("数量")}', name:'quantity', width:100, editable:true, edittype:'text'},
			{header:'${text("单价")}', name:'unitPrice', width:150, editable:true, edittype:'text'},
			{header:'${text("车辆总价")}', name:'amount', width:150, editable:true, edittype:'text'},
			{header:'${text("客户代理费(RMB)")}', name:'agencyFee', width:150, editable:true, edittype:'text'},
			{header:'${text("客户风险保证金(RMB)")}', name:'riskMargin', width:250, editable:true, edittype:'text'},
			{header:'${text("客户预收费用(RMB)")}', name:'prePay', width:150, editable:true, edittype:'text'},
			{header:'${text("客户费用合计(RMB)")}', name:'totalCost', width:150, editable:true, edittype:'text'},
			{header:'${text("交货地点")}', name:'tradingLocation', width:150, editable:true, edittype:'text'},
			{header:'${text("资方代理费(RMB)")}', name:'agencyFee1', width:150, editable:true, edittype:'text'},
			{header:'${text("资方风险保证金(RMB)")}', name:'riskMargin1', width:250, editable:true, edittype:'text'},
			{header:'${text("服务订单ID")}', name:'serviceOrderId.serviceOrderId', editable:true, hidden:true},
			{header:'${text("操作")}', name:'actions', hidden: true}
		],

		// 编辑表格参数
		frozenCols:true,
		editGrid: false,				// 是否是编辑表格
		editGridInitRowNum: 1,		// 编辑表格的初始化新增行数
		editGridAddRowBtn: $('#serviceOrderDetailDataGridAddRowBtn'),	// 子表增行按钮
		editGridAddRowInitData: {serviceOrderDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据
		showFooter: true, // 是否显示底部合计行
		// 编辑表格的提交数据参数
		editGridInputFormListName: 'serviceOrderDetailList', // 提交的数据列表名
		editGridInputFormListAttrs: 'status,serviceOrderDetailId,rowNumber,carId,frameNumber,brand,area,model,displacement,energyType,customsTariffRate,quantity,unitPrice,amount,agencyFee,riskMargin,prePay,totalCost,tradingLocation,logisticsStatus,lockFlag,serviceOrderId.serviceOrderId,', // 提交数据列表的属性字段

		// 加载成功后执行事件
		ajaxSuccess: function(data){
			let amount = '${serviceOrder.totalAmount}';
			let agencyFee = '${serviceOrder.totalAgencyFee}';
			let riskMargin = parseFloat('${serviceOrder.totalRiskMargin}');
			let prepay = '${serviceOrder.totalPrePay}';
			let totalCost = '${serviceOrder.totalCost}';
			// 设置底部合计行数据(设置合计行)
			$('#serviceOrderDetailDataGrid').dataGrid("footerData", "set", {
				'amount' : Number(amount),
				'agencyFee': Number(agencyFee),
				'riskMargin': Number(riskMargin),
				'prePay': Number(prepay),
				'totalCost': Number(totalCost)
			}, false);
		}
	});
	$("#serviceOrderDetailDataGrid1").dataGrid({

		data: ${toJson(serviceOrder.relatedRecordList)},
		datatype: "local", // 设置本地数据
		autoGridHeight: function(){return 'auto'}, // 设置自动高度

		// 设置数据表格列
		columnModel: [
			{header:'${text("单据编号")}', name:'billCode', width:300 },
			{header:'${text("日期")}', name:'date', width:150, },
			{header:'${text("费用项目")}', name:'expenseItem', width:150, editable:true, edittype:'text'},
			{header:'${text("应收金额")}', name:'yingshouAmount', width:150, editable:true, edittype:'text'},
			{header:'${text("应付金额")}', name:'yingfuAmount', width:150, editable:true, edittype:'text'},
			{header:'${text("实收金额")}', name:'shishouAmount', width:150, editable:true, edittype:'text'},
			{header:'${text("实付金额")}', name:'shifuAmount', width:150, editable:true, edittype:'text'},
			{header:'${text("预收金额")}', name:'yushouAmount', width:150, editable:true, edittype:'text'},
			{header:'${text("预付金额")}', name:'yufuAmount', width:150, editable:true, edittype:'text'},
		],

		// 编辑表格参数
		editGrid: false,				// 是否是编辑表格

		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
</script>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.closeCurrentTabPage(function(contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});

	$("#editView").click(function () {
		var id = $("#serviceOrderId").val();
		var URL = '${ctx}/order/serviceorder/serviceOrder/form?serviceOrderId=' + id;
		window.location.href =URL;
	});

	paymentMethodChange();
	function paymentMethodChange(){
		$.ajax({
			type : "post",
			async : false,
			url : "${ctx}/order/serviceorder/serviceOrder/getList",
			data : {
				'supplierId' : $("#investorId").val(),
				'paymentMethod' : $("#paymentMethod").val()
			},
			dataType : "json",
			success : function(msg) {
				$("#marginExpenseRatioId").empty();
				if (msg.length > 0) {
					for (var i = 0; i < msg.length; i++) {
						var partId = msg[i].id;
						var partName = msg[i].name;
						var option = $("<option>").attr({
							"value" : partId
						}).text(partName);
						$("#marginExpenseRatioId").append(option);
					}
					$("#marginExpenseRatioId option:first").prop("selected", 'selected');
					$("#marginExpenseRatioId").change();

				}
			},
			error : function(json) {
				$.jBox.alert("网络异常！");
			}
		});
	}

	$("#submit").click(function(){
		js.confirm('确认提交吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/submit",
				data: {"orderId": $("#serviceOrderId").val()},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});

	});

	$("#cancel").click(function(){
		js.confirm('确认取消吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/cancel",
				data: {"orderId": $("#serviceOrderId").val()},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});

	});

	$("#updateVersion").click(function(){
		js.confirm('确认更新版本吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/updateVersion",
				data: {"orderId": $("#serviceOrderId").val()},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	});

	$('#goLetterCredit').click(function () {
		let serviceOrderId = $("#serviceOrderId").val();
		window.location.href = "${ctx}/financial/lettercredit/letterCredit/goLetterCredit?serviceOrderId=" + serviceOrderId;
	})

	$('#goServiceInvoice').click(function () {
		let serviceOrderId = $("#serviceOrderCode").val();
		let customerId = $("#customerCode").val();
		window.location.href = "${ctx}/agreement/serviceinvoice/tserviceInvoice/form?serviceOrderId=" + serviceOrderId + "&customerId=" + customerId;
	})

	$(".arriveReminder").click(function () {
		var id = $("#serviceOrderId").val();
		var URL = '${ctx}/financial/arrivalreminder/arrivalReminder/createArrivalReminder?serviceOrderId=' + id;
		window.location.href =URL;
	});

	$("#overseaswarehouse").click(function () {
		var id = $("#serviceOrderId").val();
		var URL = '${ctx}/logistics/overseaswarehouse/overseasWarehouse/createFromServiceOrder?serviceOrderId=' + id;
		window.location.href =URL;
	});

	$("#ok").click(function(){
		js.confirm('确认通过吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/ok",
				data: {"orderId": $("#serviceOrderId").val()},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	});

	$("#reject").click(function(){
		js.confirm('确认拒绝吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/reject",
				data: {"orderId": $("#serviceOrderId").val()},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	});

	$('#goBZJ').click(function () {
		js.confirm('确认生成保证金预收支吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/goBZJ",
				data: {"serviceOrderId": $("#serviceOrderId").val()
				},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	})

	$('#goYS').click(function () {
		js.confirm('确认生成预收费用吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/goYS",
				data: {"serviceOrderId": $("#serviceOrderId").val()
				},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	})

	$('#goDLFYSZ').click(function () {
		js.confirm('确认生成代理费预收支吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/goDLFYSZ",
				data: {"serviceOrderId": $("#serviceOrderId").val()
				},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	})

	$('#goDLFSZ').click(function () {
		js.confirm('确认生成代理费收支吗？', function(data){
			$.ajax({
				type: "POST",
				async : false,
				url: "${ctx}/order/serviceorder/serviceOrder/goDLFSZ",
				data: {"serviceOrderId": $("#serviceOrderId").val()
				},
				success: function (data) {
					js.showMessage(data.message);
					location.reload();
				}
			});
		});
	})


</script>











